/*
 * File State.java 
 */
package cs.model;

import java.util.Observable;

/**
 * The class State is to store the state of the local user 
 * (connected, offline, and in an error state).<br>
 * Accessible by both  network and GUI view, 
 * it allows to adapt actions of the user and the network 
 * based on its status.<p>
 * Package  cs.model
 * Project ChatSystemG1 - INSA 4INFOA1 - 2013/2014
 * @author Julie DUMONS & Juste OUEDRAOGO
 */
public class  State extends Observable {

	/**
	 * LocalUserState state
	 * OFFLINE : When opening the application, the local user has not clicked on connect.
	 * ONLINE : The user is connected on the port and listen incoming messages
	 * ERROR: The network has detected an exception that prevents the user from continuing to use the cat normally.
	 */
	public static enum LocalUserState {OFFLINE, ONLINE, ERROR};
	
	/**
	 * Current State
	 */
	private static LocalUserState currentState ; 
	
	
	/**
	 * Default constructor : DECONNECTED
	 */
	public State() {
		currentState = LocalUserState.OFFLINE ; 
	}
	
	/**
	 * Getter of current state
	 * @return currentState
	 */
	public LocalUserState getCurrentState() {
		return currentState ; 
	}
	
	/**
	 * setter of current state
	 * @param state to change
	 */
	public void setcurrentState(LocalUserState state) {
		currentState = state ; 
		setChanged(); 
		notifyObservers(state);  
		clearChanged(); 
	}
}
